<div class="easyui-layout" data-options="border:false" style="overflow: auto;">
<div id="p" class="easyui-panel" style="width:700px;height:600px;padding:10px;" data-options="border:false,fit:true">
	<div class="easyui-layout" data-options="border:false,fit:true">
	    <div data-options="region:'center',fit:true,border:false" style="overflow: hidden;">
	        <table id="datagrid" data-options="border:false,fit:true" style="height: 500px;">
	        </table>
	        <div id="toolbar">
	            <table style="border-spacing:0">
	                <tr>
	                    <td>
	                        <input class="easyui-searchbox" id="search_title" style="width:150px" />
	                    </td>
	                    <td>
	                        <a href="#" id="search_medicine" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="search_title();">查找</a>
	                    </td>
	                    <td>
	                        <a href="#" id="reflush_medicine" class="easyui-linkbutton" data-options="iconCls:'icon-reload'" onclick="reflush();">刷新列表</a>
	                    </td>
	                </tr>
	            </table>
	        </div>
	    </div>
	</div>
</div>
</div>
<script>
$(function(){
    $('#datagrid').datagrid({
        url: "<?php echo CController::createUrl('community/listarticle'); ?>",
        pagination: true,
        pageSize: 20,
        fit: true,
        striped: true,
        remoteSort:false,
        fitColumns: true,
        nowrap: false,
        border: false,
        singleSelect:true,
        
        
        columns:
            [[
               {
                    title:'标题',
                    field:'title',
                    width:100
                },{
                    title:'时间',
                    field:'create_time',
                    width:100
                }
            ]],
        onClickRow:function(rowIndex,rowData){
        	var check = $('#datagrid').datagrid('getSelected');
        	var rows = rowData;
        	if($('#main-tab').tabs('exists', '文章详情')){
        		$('#main-tab').tabs('select', '文章详情');
        		$('#main-tab').tabs('getSelected').panel('refresh','<?php echo CController::createUrl('community/find')?>&article_id='+rows.article_id+'&from=list');
        	}else{
        		$('#main-tab').tabs('add',{
		            title:'文章详情',
		            content:'<iframe scrolling ="auto" frameborder="0"  src="<?php echo CController::createUrl('community/find')?>&article_id='+rows.article_id+'&from=list" style="width:100%;height:100%"></iframe>',
		            closable:true
	        	});
	        	$('#main-tab').tabs('getSelected').panel('refresh','<?php echo CController::createUrl('community/find')?>&article_id='+rows.article_id+'&from=list');
	        	$('#main-tab').tabs('getSelected').css('width', 'auto');
        	}	
        },
        toolbar: '#toolbar'
    });
});

</script>